import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {AliyunOssOutputUrl} from '../../../../config/api';
import {NzMessageService, NzModalService} from "ng-zorro-antd";
import {GroupService} from "../group.service";

@Component({
  selector: 'app-winners-detail',
  templateUrl: './winners-detail.component.html',
  styleUrls: ['./winners-detail.component.scss']
})
export class WinnersDetailComponent implements OnInit {

  aliyunOssOutputUrl = AliyunOssOutputUrl;
  winnerPrizeGroup = [];
  queryParams: any;
  constructor(
  private route: ActivatedRoute,
  private groupService: GroupService,
  private _message: NzMessageService,
  private confirmServ: NzModalService,
  private router: Router
  ) { }

  ngOnInit() {
    const id = +this.route.snapshot.params['id'];
    console.log(id);
    this.getWinnerPrizeInfo(id);
  }

  getWinnerPrizeInfo(id) {
    this.groupService.getWinnerPrizeInfo(id).subscribe( res => {
      if(res.code === 2000) {
        this.winnerPrizeGroup = res.data;
      } else {
        this.winnerPrizeGroup = [];
      }
    })
  }
  goBack() {
    this.route.queryParams.subscribe(queryParams => {
      this.queryParams = queryParams;
    });
    this.router.navigate(['/member/group/list'],{
      queryParams: this.queryParams,
      relativeTo: this.route}
    );
  }



}
